home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / ansi / hercules.zip / HERCPIXL.LC < prev    next >
Text File  |  1986-09-04  |  3KB  |  121 lines

  1. /*
  2.  *    HERCPIXL.C
  3.  *    Dave Tutelman  -  last modified 8/86
  4.  *
  5.  *    This is a set of basic graphic routines for the Hercules
  6.  *    Board (or at least the SuperComputer version of it; I assume
  7.  *     that they work with the real thing).
  8.  *        alfa ()        puts us in alphanumeric mode.
  9.  *        grafix (page)    puts us in graphics mode in page 0 or 1
  10.  *        pixel (x,y,val)    puts a pixel at <x,y>. Bright dot if
  11.  *                val=1, dark dot if val=0.
  12.  *         dchar (x,y,c)    puts character "c" at <x,y>. Note that
  13.  *                character raster is 90 x 29.
  14.  *        swpage (page)    switches to a different page.
  15.  *            waitkey ()    just waits till a key is pressed.
  16.  *
  17.  *    Actually, the routines should work with any board, since the
  18.  *    BIOS calls are used throughout.  It's Hercules-specific only
  19.  *    because I've defined the graphics and alpha modes for my
  20.  *    Hercules BIOS.
  21.  *
  22.  *      Modified for Lattice C: Reid L. Brown
  23.  *                              9/4/86
  24.  */
  25.  
  26. #define VIDI    0x10        /* video interrupt, normally 10H  */
  27. #define    KBD    0x16        /* keyboard interrupt */
  28. #define ALFA_MODE    7    /* monochrome alpha mode */
  29. #define GRAF_MODE    8    /* Hercules graphics mode */
  30.  
  31. int    page = 0;
  32. struct {
  33.     unsigned ax,bx,cx,dx,si,di;
  34.         } _r;
  35.  
  36. /*
  37.  * This puts us back in alphanumeric mode 
  38.  */
  39.  
  40. alfa (dummy)
  41.     unsigned int dummy;
  42. {
  43.     _r.ax = ALFA_MODE;    /* mono 80-col mode */
  44.     int86 ( VIDI, &_r, &_r);    /* set mode */
  45. }
  46.  
  47. /*
  48.  *    This one switches us to hercules graphics mode
  49.  *        in page 0 or 1
  50.  */
  51.  
  52. grafix (newpage)
  53.     int newpage;
  54. {
  55.  
  56.     _r.ax = GRAF_MODE;    /* herc grafix mode */
  57.     int86 ( VIDI, &_r, &_r);    /* set mode */
  58.  
  59.     /*  now set the page */
  60.     swpage (newpage);
  61. }
  62.  
  63. /*
  64.  *   This writes a pixel at (x,y), where (0,0) is the upper-left
  65.  *   corner of the screen.  If val = 0 then the pixel is erased.
  66.  */
  67.  
  68. pixel (x, y, val)
  69.     int x, y, val;
  70. {
  71.  
  72.     _r.ax = 0x0C00 + val;    /* function 12      */    
  73.     _r.cx = x;
  74.     _r.dx = y;
  75.     int86 ( VIDI, &_r, &_r);    /* set mode */
  76.  
  77. }
  78.  
  79.  
  80. /*
  81.  *    dchar (x,y,c)    puts character "c" at <x,y>. Note that
  82.  *            character raster is 90 x 25.
  83.  */
  84.  
  85. dchar (x,y,c)
  86.     int x,y;
  87.     char c;
  88. {
  89.  
  90.     _r.ax = 2*256;        /* AH=Fn#2 */
  91.     _r.dx = 256*y + x;        /* DH=row, DX=col */
  92.     _r.bx = page * 256;        /* BH=page  */
  93.     int86 ( VIDI, &_r, &_r);    /* set cursor */
  94.  
  95.     _r.ax = 10*256 + (int) c;    /* AH=Fn#10, AL=char */
  96.     _r.bx = page * 256;        /* BH=page */
  97.     _r.cx = 1;            /* CX=count */
  98.     int86 ( VIDI, &_r, &_r);    /* write character */
  99. }
  100.  
  101.  
  102. /*
  103.  *    This one switches us to a different page, without changing
  104.  *    the contents of that page.
  105.  */
  106.  
  107. swpage (newpage)
  108.     int     newpage;
  109. {
  110.     page = newpage;
  111.     _r.ax = 0x500 + page;        /* new page function */
  112.     int86 ( VIDI, &_r, &_r );    /* interrupt call */
  113. }
  114.  
  115.  
  116. waitkey ()
  117. {
  118.     _r.ax = 0;        /* keyboard blocking read function */
  119.     int86 (KBD, &_r, &_r );
  120. }
  121.